import request from "@/utils/request";

export const add = (params) => {
  const {
    jobName,
    groupName,
    cronExpress,
    jobParam,
    retryCount,
    retryInterval,
  } = params;
  return request.post("/batch/job/add", {
    jobName,
    groupName,
    cronExpress,
    jobParam,
    retryCount,
    retryInterval,
  });
};

export const getPage = (pageNo, pageSize) => {
  return request.post("/batch/job/page", {
    pageNo,
    pageSize,
  });
};

export const remove = (params) => {
  const { jobName, groupName } = params;
  return request.delete(`/batch/job/remove/${jobName}/${groupName}`);
};

export const edit = (params) => {
  const { jobName, groupName, cronExpress } = params;
  return request.post("/batch/job/edit", {
    jobName,
    groupName,
    cronExpress,
  });
};

export const pause = (params) => {
  const { jobName, groupName } = params;
  return request.post(`/batch/job/pause/${jobName}/${groupName}`);
};

export const resume = (params) => {
  const { jobName, groupName } = params;
  return request.post(`/batch/job/resume/${jobName}/${groupName}`);
};

export const run = (params) => {
  const { jobName, groupName } = params;
  return request.post(`/batch/job/run/${jobName}/${groupName}`);
};
